package minh.bac.wcbrazil2014.thongke;

import minh.bac.wcbrazil2014.R;
import minh.bac.wcbrazil2014.favorite.ListViewTeamFM;
import minh.bac.wcbrazil2014.favorite.FavoriteFragment;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class ThongKeFragment extends Fragment {
	public static ThongKeFragment newInstance()
	{
		ThongKeFragment fragment = new ThongKeFragment();
		return fragment;
	}

	static FragmentManager fragmentManager;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		View rootView = inflater.inflate(R.layout.thongke_layout, container,
				false);
		fragmentManager = this.getChildFragmentManager();
		switchFragment(R.id.container_thongke, new ListViewXepHangFM(), true, null);
		return rootView;
	}

	
	@Override
	public void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
	}


	public static void switchFragment(int idContainer, Fragment fragment,
			boolean addToBackStack, String TAG) {
		if (addToBackStack) {
			if (TAG != null) {
				fragmentManager.beginTransaction()
						.replace(idContainer, fragment, TAG)
						.addToBackStack(TAG).commit();
			} else {
				fragmentManager.beginTransaction()
						.replace(idContainer, fragment).addToBackStack(null)
						.commit();
			}
		} else {
			if (TAG != null) {
				fragmentManager.beginTransaction()
						.replace(idContainer, fragment, TAG)
						.addToBackStack(TAG).commit();
			} else {
				fragmentManager.beginTransaction()
						.replace(idContainer, fragment).addToBackStack(null)
						.commit();
			}
		}
	}
}
